import { defHttp } from '/@/utils/http/axios';

enum Api {
  GetConfigs = '/blog/configs/',
  GetConfigByKey = '/blog/configs/key',
  GetConfigsByPageType = '/blog/configs/page',
}

/**
 * 获取所有配置
 */
export const getBlogConfigs = () => {
  return defHttp.get({ url: Api.GetConfigs });
};

/**
 * 根据配置键获取配置
 */
export const getBlogConfigByKey = (configKey: string) => {
  return defHttp.get({ url: Api.GetConfigByKey, params: { configKey } });
};

/**
 * 根据页面类型获取配置
 */
export const getBlogConfigsByPageType = (pageType: 'home' | 'about' | 'contact' | 'global') => {
  return defHttp.get({ url: Api.GetConfigsByPageType, params: { pageType } });
};

/**
 * 获取首页配置
 */
export const getHomeConfigs = () => {
  return getBlogConfigsByPageType('home');
};

/**
 * 获取关于我页面配置
 */
export const getAboutConfigs = () => {
  return getBlogConfigsByPageType('about');
};

/**
 * 获取联系我页面配置
 */
export const getContactConfigs = () => {
  return getBlogConfigsByPageType('contact');
};

/**
 * 获取全局配置
 */
export const getGlobalConfigs = () => {
  return getBlogConfigsByPageType('global');
};

export function fetchSkills() {
  return defHttp.get({ url: '/api/blog/config/byKey', params: { key: 'skills' } });
} 